<template>
	<view class="all">
		<TotleVue title="套餐详情"></TotleVue>
		<p style="font-size: 40rpx;width: 90%;margin: 1rem auto;">{{goodsBox.name}}</p>
		<p class="topType">
			<span>{{goodsBox.is_out}}</span>
			<span>|</span>
			<span>{{goodsBox.reservation}}</span>
			<span>|</span>
			<span>{{goodsBox.refund}}</span>
			<span>|</span>
			<span>{{goodsBox.statking}}</span>
		</p>
		<view>
			<scroll-view class="scroll-view_H" scroll-x="true" scroll-left="120">
				<view id="demo1" class="scroll-view-item_H uni-bg-red" v-for="(item,index) in goodsBox.imgs" :key="index">
					<img :src="item" alt="" class="item-img" />
				</view>
			</scroll-view>
		</view>
		<view class="Notice">
			<p>购买须知</p>
			<ul>
				<li v-for="(ele,index) in goodsBox.purchase" :key="index">
					<p><span>{{ele.name}}</span><span>￥{{ele.price}}</span></p>
				</li>
			</ul>
		</view>
		<view style="width: 100%;height: 0.5rem; background-color: black;"></view>
		<view class="boxText">
			<p style="font-size: 40rpx;">购买须知</p>
			<p style="font-size: 30rpx;color: orange;">有效期</p>
			<p style="font-size: 27rpx;color: #9caaaa;">{{goodsBox.end_time}}</p>
			<p style="font-size: 30rpx;color: orange;">使用时间</p>
			<p style="font-size: 27rpx;color: #9caaaa;">{{goodsBox.ok_time}}</p>
			<p style="font-size: 30rpx;color: orange;">不可使用时间</p>
			<p style="font-size: 27rpx;color: #9caaaa;">{{goodsBox.no_time}}</p>
			<p style="font-size: 30rpx;color: orange;">适用范围</p>
			<p style="font-size: 27rpx;color: #9caaaa;">{{goodsBox.range}}</p>
		</view>
		<view style="width: 100%;height: 0.5rem; background-color: black;"></view>
		<view class="shopCard">
			<p style="font-size: 40rpx;">商家介绍</p>
			<view class="shopBox">
				<img src="" alt="" clsss="shopImg" />
				<p class="shopBoxText">{{goodsBox.store.text}}</p>
				<p>
					<span style="margin: 0.5rem;">{{goodsBox.store.stresst}}</span>
					<span style="margin: 0.5rem;">|</span>
					<span style="margin: 0.5rem;">{{goodsBox.store.type}}</span>
				</p>
				<view class="tel">
					<p style="display: flex;width: 80%;justify-content: center;">
						<u-icon name="map-fill" color="white" size="40rpx" style="margin-right: 1rem;"></u-icon>
						<span class="telText">
							{{goodsBox.store.shopname}}
						</span>
					</p>
					<p style="background-color: black;padding: 0.5rem;border-radius: 50%;"><u-icon name="phone-fill"
							color="orange" size="40rpx"></u-icon></p>
				</view>
			</view>
		</view>

		<view style="width: 100%;height: 2.5rem; background-color: black;"></view>
		<view class="cardBottom">
			<p>
				<span style="font-size: 45rpx;color: orangered;">￥{{goodsBox.price*goodsBox.detailts}}</span>
				<span><s>{{goodsBox.price}}</s></span>
			</p>
			<button @click="getShopOk(goodsBox._id)">立即选购</button>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { onMounted, ref } from "vue";
	import TotleVue from "../../Totle.vue";
	import { get_goods_box } from "../../../../api/api";
	const scrollTop = ref<Number>(0);
	const old = ref<object>({ scrollTop: 0 });


	const upper = (e : any) => {
		console.log(e)
	};
	const lower = (e : any) => {
		console.log(e)
	};

	const goTop = (e : any) => {
		// 解决view层不同步的问题
		scrollTop.value = old.value.scrollTop,
			this.$nextTick(function () {
				scrollTop.value = 0
			});
		uni.showToast({
			icon: "none",
			title: "纵向滚动 scrollTop 值已被修改为 0"
		});
	};

	const props = defineProps()

	//商品信息
	const goodsBox = ref<object>({})
	//获取商品信息
	const getGoodsBox = async () => {
		let res = await get_goods_box({id:props.id})
		goodsBox.value = res.data[0];
	};
	onMounted(() => {
		getGoodsBox()
	});
	
	//跳转到支付界面
	const getShopOk=(id:string)=>{
		uni.navigateTo({
				url:`/pages/Find/Happy/Shopdatails/ShopOk/ShopOk?id=${id}`
			})
	}
</script>

<style lang="scss" scoped>
	.all {
		width: 100vw;
		height: 120vh;
		background-color: #191919;
		color: white;
	}

	.topType {
		width: 90%;
		margin: auto;

		span {
			font-size: 20rpx;
			margin: 0 0.2rem;
		}
	}

	.scroll-Y {
		height: 300rpx;
	}

	.scroll-view_H {
		white-space: nowrap;
		width: 95%;
		margin: auto;
		margin-top: 1.5rem;
	}

	.scroll-view-item {
		height: 300rpx;
		line-height: 300rpx;
		text-align: center;
		font-size: 36rpx;
	}

	.scroll-view-item_H {
		display: inline-block;
		width: 30%;
		height: 200rpx;
		line-height: 300rpx;
		text-align: center;
		font-size: 36rpx;
		background-color: cadetblue;
		margin-right: 2rem;
	}

	.item-img {
		width: 100%;
		height: 100%;
	}

	.Notice {
		width: 90%;
		margin: auto;
		margin-top: 1rem;

		p {
			font-size: 40rpx;
			display: flex;
			justify-content: space-between;
			margin: 1rem 0;

			span {
				font-size: 30rpx;
			}
		}
	}

	.boxText {
		width: 90%;
		margin: auto;
		padding-top: 1rem;

		p {
			margin-bottom: 0.8rem;
		}
	}

	.shopBoxText {
		width: 100%;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		margin: 0.5rem;
	}

	.shopCard {
		width: 90%;
		// height: 100%;
		margin: auto;
		margin-top: 1rem;
	}

	.tel {
		width: 97%;
		height: 100rpx;
		background-color: #21262d;
		margin: 1rem auto;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 2.5rem 1rem;
		border-radius: 10rpx;
	}

	.telText {
		width: 80%;
		// height: 100%;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.cardBottom {
		width: 100%;
		height: 100rpx;
		background-color: black;
		position: fixed;
		bottom: 0;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 1rem;

		button {
			width: 27%;
			height: 70%;
			background-color: orangered;
			border-radius: 70rpx;
			color: white;
			left: 100rpx;
			font-size: 30rpx;
		}
	}
</style>